package com.farmUni.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Data
public class LuckyUser {
    public Long id;
    public List<LuckyArticle> articleList = new ArrayList<>();

    public LuckyUser() {}

    public LuckyUser(Long id) {
        this.id = id;
    }

    public LuckyUser set(Long ArticleId, int score) {
        this.articleList.add(new LuckyArticle(ArticleId, score));
        return this;
    }

    public LuckyArticle find(Long articleId) {
        for (LuckyArticle luckyArticle : articleList) {
            if (Objects.equals(luckyArticle.articleId, articleId)) {
                return luckyArticle;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId='" + id + '\'' +
                '}'
                ;
    }
}
